home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
djgpp
/
tests
/
t14.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-04
|
533b
|
31 lines
#include <stdio.h>
#include <fcntl.h>
main()
{
FILE *f;
int fd;
char buf[10];
f = fopen("t14.dat", "w");
fwrite("abcdefghijklmnopqrstuvxyz\n", 26, 1, f);
fclose(f);
fd = open("t14.dat", O_WRONLY|O_BINARY);
if (fd < 0)
return -1;
ftruncate(fd, 20);
close(fd);
f = fopen("t14.dat", "r");
fread(buf, 5, 1, f);
buf[5] = 0;
printf("first pass: %s\n", buf);
rewind(f);
fread(buf, 5, 1, f);
buf[5] = 0;
printf("second pass: %s\n", buf);
fclose(f);
return 0;
}